package org.example.pool;

import java.util.concurrent.*;

public class Main {
    public static void main(String[] args) {
        //自己new出来的线程池对象
        /*
        1.核心线程数 3
        2.最大线程数 10
        3.时长 1000
        4.时长单位 TimeUnit。MILLSECONDS  毫秒
        5.任务队列 存放来不及处理的任务。
        6.线程工厂类，创建线程Executors.defaultThreadFactory()
        7.拒绝策略 new ThreadPoolExecutor.AbortPolicy()
         */
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1,
                1000, TimeUnit.MILLISECONDS,
                new ArrayBlockingQueue<Runnable>(1),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.CallerRunsPolicy()
        );
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        threadPoolExecutor.submit(()->{
            while(true){

            }
        });
        threadPoolExecutor.submit(()->{
            while(true){

            }
        });
        threadPoolExecutor.submit(()->{
            System.out.println("helloworld");
        });

        System.out.println(Thread.currentThread().getName()+":hello zhangsan");
    }
}
